<?php

class CommonAction extends Action {


    public function _initialize() {
        $this->setLayout();
        $this->assign('act', MODULE_NAME);
        $this->assign('meth', ACTION_NAME);
        $this->assign('homePage', false);
        $this->getLastNews();
        $this->getNav();
    }

   

    public function setLayout() {
        $layout = $this->_get('layout');
        if ($layout) {
            C('LAYOUT_NAME', 'Layout/' . $layout);
        }
        $this->assign('layout_name', C('LAYOUT_NAME'));
    }

    public function getLastNews(){
        $model = M('News');
        $news = $model->order('news_id desc')->limit(4)->select();
        $this->assign('lastnews',$news);
    }

    public function getNav(){
        $art = M('Article');
        $navs = $art->where('category_id = 3')->order('article_id asc')->select();
        $this->assign('topnavs',$navs);
    }


}
